package gao.xiaolei.dao;

import gao.xiaolei.entity.GroupClass;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import javax.persistence.ManyToMany;
import java.util.List;

@Repository("GroupClassesDao")
public interface GroupClassesDao extends JpaRepository<GroupClass,String> {

    public Integer countByClassId(String classId);

    @Query("select groupId from GroupClass where classId=:classId")
    public List<String> findGroupIdByClassId(@Param("classId") String classId);

    @Query("select classId from GroupClass where groupId=:groupId")
    public List<String> findClassIdByGroupId(@Param("groupId") String groupId);

    @Modifying
    public void deleteByGroupId(String groupId);
}
